package designpatterns.abstractfactory;

import java.util.Objects;

import designpatterns.abstractfactory.intf.Color;
import designpatterns.abstractfactory.intf.Shape;

/**
 * @description:
 * @author: Lidong
 * @time: 2020/7/21 21:47
 **/
public class App {

    public static void main(String[] args) {
        //获取形状工厂
        AbstractFactory shape = FactoryProducer.getFactoryInstance("shape");

        Shape rectangle = Objects.requireNonNull(shape).getShape("rectangle");
        rectangle.draw();

        Shape square = shape.getShape("square");
        square.draw();

        // 获取颜色工厂
        AbstractFactory colorFactory = FactoryProducer.getFactoryInstance("COLOR");
        Color color1 = Objects.requireNonNull(colorFactory).getColor("RED");
        color1.fill();
    }

}
